package com.hanhanxiaochong.zhongxiangchuanmei.view.my.act;

import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.gyf.barlibrary.ImmersionBar;
import com.hanhanxiaochong.zhongxiangchuanmei.R;
import com.hanhanxiaochong.zhongxiangchuanmei.bean.StorRewardBean;
import com.hanhanxiaochong.zhongxiangchuanmei.presenter.my.StorRewardPresenter;
import com.hanhanxiaochong.zhongxiangchuanmei.util.SharedPreferencesUtil;
import com.hanhanxiaochong.zhongxiangchuanmei.view.base.BaseActivity;
import com.hanhanxiaochong.zhongxiangchuanmei.view.iview.IStorRewardView;
import com.hanhanxiaochong.zhongxiangchuanmei.view.my.adapter.StorRewardAdapter;

import java.util.List;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * Author : 贾桐
 * E-mail : 653773284@qq.com
 * Time   : 2018/6/9.
 * Desc   :
 */

public class StorRewardActivity extends BaseActivity<StorRewardPresenter> implements IStorRewardView {

    @BindView(R.id.img_left)
    ImageView imgLeft;
    @BindView(R.id.txt_title)
    TextView txtTitle;
    @BindView(R.id.img_right)
    ImageView imgRight;
    @BindView(R.id.rl_topview)
    RelativeLayout rlTopview;
    @BindView(R.id.txt_stor_reward_money)
    TextView txtStorRewardMoney;
    @BindView(R.id.recyclerview_stor_reward)
    RecyclerView recyclerviewStorReward;

    private String token;
    private StorRewardAdapter storRewardAdapter;

    @Override
    protected void initView() {
        setContentView(R.layout.activity_stor_reward);
        token = SharedPreferencesUtil.getsInstances(this).getLoginInfo().getToken();
    }

    @Override
    protected void initPresenter() {
        mPresenter = new StorRewardPresenter(this);
    }

    @Override
    protected void init() {
        setTopView();
        String money = getIntent().getStringExtra("money");
        txtStorRewardMoney.setText(money);
        mPresenter.getStorReward(token);
    }

    private void setTopView() {
        ImmersionBar.with(StorRewardActivity.this).fitsSystemWindows(true).statusBarColor(R.color
                .blue2).statusBarDarkFont(false).init(); //解决状态栏和布局重叠问题;
        rlTopview.setBackgroundColor(getResources().getColor(R.color.blue2));
        imgLeft.setImageResource(R.mipmap.icon_close_white);
        txtTitle.setText("推荐门店分红账户");
        txtTitle.setTextColor(getResources().getColor(R.color.white));
    }

    @OnClick({R.id.ll_leftview, R.id.ll_rightview})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.ll_leftview:
                finish();
                break;
            case R.id.ll_rightview:
                break;
        }
    }

    @Override
    public void getStorReward(List<StorRewardBean> rewardBeanList) {
        storRewardAdapter = new StorRewardAdapter(mContext, R.layout.item_mywallet_lsmx, rewardBeanList);
        recyclerviewStorReward.setLayoutManager(new LinearLayoutManager(mContext));
        recyclerviewStorReward.setAdapter(storRewardAdapter);
    }
}
